<?php 

namespace Home\Controller ;  
use Think\Controller ; 

class ApiController extends Controller {
	function _initialize(){

	}

	/**
	 * 获取商品分类 , 
	 * @param $parent_id 父级id 顶级为 0 
	 */
	function getcategory(){
		 $parent_id = I('get.parent_id'); // 商品分类 父id  
            $list = M('goods_category')->where("parent_id = $parent_id")->select();
        foreach($list as $k => $v)
            $html .= "<option value='{$v['id']}'>{$v['name']}</option>";        
        exit($html);
	}

	/**
	 * 通过父级分类获取班级 . 
	 */
	function getgoodsbycat(){
		$catid = I('get.cat');
		$list = M('Goods')->where(array('cat_id' => $catid))->select();
		$html = '';
		if($list){
			foreach($list as $k=>$v){
				  $html .= "<option value='{$v['goods_id']}'>{$v['goods_name']}</option>";      
			}
		}
		exit($html);
	}

	/**
	 * 通过班级查找目录
	 */
	function getcoverbyclass(){
		$cid = I('get.cid') ; 
		$list = M('CourseInfo')->where(array('gid' => $cid))->select();
		$html = '';
		if($list){
			foreach($list as $k=>$v){
				  $html .= "<option value='{$v['id']}'>{$v['title']}</option>";      
			}
		}
		exit($html);
	}




}